define(function(require, exports, module) {
    var ALL = require("../../common/all"),
        CONFIG = ALL.CONFIG,
        METHOD = ALL.METHOD,
        Dialog = ALL.Dialog,
        Init = ALL.Init;

    var _Dialog = new Dialog({
        title : "提示",
        content : "<p>是否通过临停？</p>",
        text4Btn: ["确定", "取消"],
        class4Btn: ["", "line"]
    });

    var _vm = Init.initVue({
        data : {
            col_id : "",
            status : "",
            admin_id : "",
            list : [],
            cur : 1,
            all : 0,
            search : false
        },
        methods: {
            reSearch : function() {
                this.search = true;
                this.getData(1);
            },
            reset : function() {
                this.search = false;
                _vm.col_id = "";
                _vm.admin_id = "";
                _vm.status = "";
            },
            getData : function(n) {
                var obj = {
                    page: n, num: 10,
                    type : 1,
                    col_id : _vm.col_id,
                    admin_id : _vm.admin_id,
                    status : _vm.status
                };
                METHOD.loading.show();
                METHOD.ajax("tradesuspend/list",obj).done(function(json){
                    METHOD.loading.hide();
                    _vm.list = json.data;
                    _vm.all = json.page.pages;
                }).fail(function(){
                    METHOD.loading.hide();
                });
            },
            operate : function(id,type) {
                var url;

                if (type == 1) {
                    _Dialog.changeCfg({content : "<p>是否通过临停？</p>"});
                    url = "tradesuspend/operate/pause/pass";
                } else if (type == 2) {
                    _Dialog.changeCfg({content : "<p>是否拒绝临停？</p>"});
                    url = "tradesuspend/operate/pause/refuse";
                } else if (type == 3) {
                    _Dialog.changeCfg({content : "<p>是否停止临停？</p>"});
                    url = "tradesuspend/operate/pause/stop";
                } else if (type == 4) {
                    _Dialog.changeCfg({content : "<p>是否复牌？</p>"});
                    url = "tradesuspend/operate/pause/resumed";
                };

                _Dialog.showUI(function(i) {
                    var obj = { sus_id : id, type : type };

                    if (i == 0) {
                        METHOD.loading.show();
                        METHOD.ajax(url, obj, {type:"post"}).done(function(json){
                            METHOD.loading.hide();
                            _vm.getData(1);
                        }).fail(function(){
                            METHOD.loading.hide();
                        });
                    }
                    this.hideUI();
                });
            }
        }
    });

    _vm.getData(1);

});

